package Probleme;

import java.util.Random;
import java.util.Vector;

import Objet.ListeObjets;
import Objet.Objet;

public class Generator {
	public Vector<Instance> instances;
	public int nbinst;
	public int op;
	public int ow;
	public int t;
	
	public Generator(int nbinst, int t, int ow) {
		this.t = t;
		this.op = ow;
		this.nbinst = nbinst;
		this.instances = new Vector<Instance>();
		for (int i = 0; i < nbinst; i++) {
			this.instances.add(this.MakeInstance(t, this.op));
		}
	}
	
	public Instance MakeInstance(int taille, int ordrepoids) {
		Instance pb;
		int poids;
		ListeObjets x;
		x = new ListeObjets();
		
		Random r = new Random();
		int nbObjets = r.nextInt((taille - 1) - 1);
		
		for (int i = 0; i < nbObjets; i++) {
			poids = (int) (Math.random() * ordrepoids) + 1;
			x.ajout(new Objet(i, poids));
		}
		
		x.trie();
		
		poids = x.getPoidsMax() + r.nextInt(x.getPoids()- x.getPoidsMax());
				
		System.out.println("TEEEEEEST " + poids);
		pb = new Instance(taille, x, poids);
		return pb;
	}
}
